﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;

public partial class UserSetup_EditPWD : System.Web.UI.Page
{
    UserInfoManager dllUserInfoManager = new UserInfoManager();
    Authentication dllAuthentication = new Authentication();
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    ///// <summary>
    ///// 同步修改OA系统的同用户密码（不启用，只允许OA修改计划系统密码，不允许计划反向修改）
    ///// </summary>
    ///// <remarks>修改计划系统密码的同时，调用OA修改密码的WebService修改OA系统的密码。</remarks>
    //void OAPwdModify()
    //{
    //    Model.UserInfo objUserInfo = new Model.UserInfo();
    //    string username = objUserInfo.UserName;
    //    string password = this.txtNewPWD.Text.Trim();

    //    string OpenPage = " Username = " + username + "&Password=" + this.txtOldPWD.Text.Trim() + "&newPassword=" + password + "&sType=1&loginTime=" + DateTime.Now + "";
    //    //加密字符串传递至OA
    //    OpenPage = OACommon.OAEncrypt.Encrypt(OpenPage);
    //    Response.Redirect("http://dev01.dooshion.com/domcfg.nsf/LoginPage?OpenPage=" + OpenPage);
    //}

    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnModify_Click(object sender, EventArgs e)
    {
        //Utility.HttpHelp.alert("请从OA修改您的密码！",this.Page);

        Model.UserInfo objUserInfo = new Model.UserInfo();
        int i = dllAuthentication.UserLogin(objUserInfo.UserName, this.txtOldPWD.Text.Trim());
        if (i > 0)
        {
            object[] _value = new object[2];
            _value[0] = objUserInfo.UserName;
            _value[1] = this.txtNewPWD.Text.Trim();
            //_value[1] = BLL.Authentication.EncryptPassword(this.txtNewPWD.Text.Trim(), Authentication.EncryptType.MD5);
            int result = dllAuthentication.editUserPassWord(_value);
            if (result > 0)
            {
                Utility.HttpHelp.alert("修改密码成功", Page);
                //Utility.HttpHelp.redirectPage("../WelCome.aspx");
            }
            else
            {
                Utility.HttpHelp.alert("密码修改错误，请重试！", Page);
            }
        }
    }

    /// <summary>
    /// 返回事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Utility.HttpHelp.redirectPage("../WelCome.aspx");
    }
}
